package com.dx.security.component;

import com.dx.cache.Cache;
import com.dx.enums.CacheNameEnum;
import com.dx.security.dto.MenuDTO;
import com.dx.service.user.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @version 1.0
 * @author: YU.TAN
 * @date: 2023/6/27 23:55
 * @Description:
 */
@Component
public class InitProcessor {
    @Autowired
    private MenuService menuService;
    @Autowired
    private Cache caffeineCache;

    @PostConstruct
    public void init() {
        List<MenuDTO> permissionInfoList = menuService.listMenu();
        permissionInfoList.forEach(permissionInfo -> {
            caffeineCache.put(CacheNameEnum.PERMISSION, permissionInfo.getPath() , permissionInfo);
        });
    }
}
